package com.longcai.piaojia.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/1/10.
 */
@HttpInlet(Conn.ACTIVITY_SUBSCRIBE_EQUIP)
public class LatestOrderToolsGet extends BaseAsyGet<LatestOrderToolsGet.OrderToolEntity> {

    public String id;

    public LatestOrderToolsGet(AsyCallBack<OrderToolEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected OrderToolEntity parser(JSONObject object) throws Exception {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            OrderToolEntity orderToolEntity = new OrderToolEntity();

            JSONArray array = object.optJSONArray("data");

            for (int i = 0; i < array.length(); i++) {

                JSONObject entityObject = array.optJSONObject(i);

                ToolsEntity toolsEntity = new ToolsEntity();

                toolsEntity.title = entityObject.optString("title");
                toolsEntity.price = entityObject.optString("price");
                toolsEntity.attr = entityObject.optString("attr");

                orderToolEntity.toolsEntityList.add(toolsEntity);

            }

            return orderToolEntity;
        }

        return null;
    }

    public static class OrderToolEntity {

        public List<ToolsEntity> toolsEntityList = new ArrayList<>();
    }

    public static class ToolsEntity {

//        "title": "衣服",  //标题
//                "price": "20.00", //价格
//                "attr": "件" //规格
        public String title, price, attr;
        public int count = 0;

    }
}
